//
//  LoginInputView.m
//  ProjectforHDX
//
//  Created by Jaesun on 16/6/30.
//  Copyright © 2016年 H.DX. All rights reserved.
//

#import "LoginInputView.h"

@implementation LoginInputView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self s_setupViews];
    }
    return  self;
}
- (void)s_setupViews {
    
    // imageView
    CGFloat imageLength = CGRectGetHeight(self.frame) - 20; // 图标边长
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10, imageLength, imageLength)];
    self.imageView.backgroundColor = [UIColor clearColor];
    [self addSubview:self.imageView];
    
    // textField
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imageView.frame) + 10, CGRectGetMinY(self.imageView.frame),CGRectGetWidth(self.frame) - imageLength - 10, CGRectGetHeight(self.imageView.frame))];
    self.textField.delegate = self;
    self.textField.font=CustomFont(14);
    [self addSubview:self.textField];
    
    // underLinelabel
    self.underLineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.frame) - 1, CGRectGetWidth(self.frame), 0.5)];
    self.underLineLabel.backgroundColor = [UtilCheck hexStringToColor:@"ededed" alpha:1];
    [self addSubview:self.underLineLabel];
}


-(void)setIconImg:(UIImage *)iconImg{
    
    self.imageView.image=iconImg;
    CGFloat imgVW=self.imageView.width;
    CGFloat imageLength=iconImg.size.width;
    self.imageView.width=imageLength;
    self.imageView.height=imageLength;
    self.imageView.left=0;
    self.imageView.top+=(imgVW-imageLength)/2;
}


//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//    
//    NSMutableString *text = [textField.text mutableCopy];
//    [text replaceCharactersInRange:range withString:string];
//    
//    NSInteger limitedLength = 16;
//    
//    if ([text length] <= limitedLength || [string isEqualToString:@""]) {
//        return YES;
//    } else {
//        //提示输入字数超标
//        [Toolobject showTextWithMessage:[NSString stringWithFormat:[UtilCheck language:@"login.limited"],(long)limitedLength]]; // 最多%ld个字符
//        
//        return NO;
//    }
//}

@end
